package edu.hunau.cxb19.oop.class15.hk;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalAdjuster;

import org.junit.Test;

/**
 *
 * @author hb
 *
 *         2020-03-16 14:42:42
 */
public class TemporalAdjusterTest {

	@Test
	public void test() {
		// 获得下一个工作日
		TemporalAdjuster temporalAdjuster = new TemporalAdjuster() {
			/**
			 * 重写方法定义矫正规则
			 */
			public Temporal adjustInto(Temporal temporal) {
				LocalDate date = (LocalDate) temporal;
				if (date.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {// 如果当前为星期五
					return date.plusDays(3);
				} else if (date.getDayOfWeek().equals(DayOfWeek.SATURDAY)) {
					return date.plusDays(2);
				} else {
					return date.plusDays(1);
				}
			}
		};
		LocalDate nextDate = LocalDate.now().with(temporalAdjuster);
		System.out.println(nextDate);
	}

}
